<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>argument转化为数组</title>
</head>
<body>

    <script>
        function foo()
        {
            //使用for循环
            // var arr = [];
            // for(el of arguments)
            // {
            //    arr.push(el); 
            // }
            // console.log(arr);

            //使用数组方法from
            // var newArr = Array.from(arguments);
            // console.log(newArr);
            
            //使用slice
            var newArr = [].slice.apply(arguments);
            var newArr2 = Array.prototype.slice.apply(arguments);
            console.log(newArr);
            console.log(newArr2);
        }

        foo(11,22,33,44,55);
    </script>
    
</body>
</html>